package action.grant;

import java.util.List;

import model.company.Companybasic;
import model.dropdown.DCommon;
import model.grant.Customgrant;
import model.personal.Personalbasic;

import service.contract.ContractService;
import service.grant.GrantService;

import core.action.BaseAction;
import exception.Exceptions;

public class ShowGrantAction extends BaseAction{
	private List<?> menu_name;
	private Integer grantid;
	private Customgrant grant;
	private String cname;
	private String ccode;
	private String codetype;
	private GrantService grantService;
	private ContractService contractService;
	
	private String title;
	
	public String execute(){
		return "success";
	}
	public String findGrantListCompany(){
		menu_name=grantService.getGrantList("Companybasic");
		title="企业客户授信详情";
		return "success";
	}
	public String findGrantListPersonal(){
		menu_name=grantService.getGrantList("Personalbasic");
		title="个人客户授信详情";
		return "success";
	}
	public String showGrantDetail() throws Exceptions{
		grant=grantService.getGrant(grantid);
		if(grant.getCustomtype().equals("1")){
			Personalbasic personal=grantService.getPersonalbasic(grant.getCustomid());
			cname=personal.getName();
			ccode=personal.getCertificatenumber();
			List<DCommon> type=contractService.getIdtypeList();
			for(DCommon tp:type){
				if(tp.getId().equals(personal.getCertificatetype())){
					codetype=tp.getName();
				}
			}
			
		}else if(grant.getCustomtype().equals("2")){
			Companybasic company=grantService.getCompanybasic(grant.getCustomid());
			cname=company.getName();
			ccode=company.getOrganizationcode();
			codetype="组织机构代码";
		}
		return "detail";
	}

	//--------------------get/set------------------------//
	public List<?> getMenu_name() {
		return menu_name;
	}

	public void setMenu_name(List<?> menu_name) {
		this.menu_name = menu_name;
	}
	public GrantService getGrantService() {
		return grantService;
	}
	public void setGrantService(GrantService grantService) {
		this.grantService = grantService;
	}
	public Integer getGrantid() {
		return grantid;
	}
	public void setGrantid(Integer grantid) {
		this.grantid = grantid;
	}
	public Customgrant getGrant() {
		return grant;
	}
	public void setGrant(Customgrant grant) {
		this.grant = grant;
	}
	public String getCname() {
		return cname;
	}
	public void setCname(String cname) {
		this.cname = cname;
	}
	public String getCcode() {
		return ccode;
	}
	public void setCcode(String ccode) {
		this.ccode = ccode;
	}
	public String getCodetype() {
		return codetype;
	}
	public void setCodetype(String codetype) {
		this.codetype = codetype;
	}
	public ContractService getContractService() {
		return contractService;
	}
	public void setContractService(ContractService contractService) {
		this.contractService = contractService;
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}

}
